import paramiko
import time

def powerset():
        ssh = paramiko.SSHClient()
        know_host = paramiko.AutoAddPolicy()
        ssh.set_missing_host_key_policy(know_host)
        ssh.connect(
            hostname="192.168.1.123",
            port=22,
            username="Administrator",
            password="Admin@9000"
        )
        execmd = "ipmcset -d powerstate -v 2"
        stdin, stdout, stderr = ssh.exec_command(execmd)
        time.sleep(1) # d:10
        stdin.write("Y")
        powerdown = str(stdout.read(), 'utf-8')
        print(powerdown)
        time.sleep(5) # d:60

        execmd = "ipmcset -d powerstate -v 1"
        stdin, stdout, stderr = ssh.exec_command(execmd)
        time.sleep(1) # d:10
        stdin.write("Y")
        powerout = str(stdout.read(), 'utf-8')
        print(powerout)

        ssh.close()

powerset()